#include  "mainwidget.h"
#include   "util.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //读取配置文件
    QString language_value;
    QString language_suffix = QString("zh");
    LANGUAGE language = UI_ZH;
    bool is_read = Util::readInit(QString("./user.ini"),
                                  QString("language"),
                                  language_value);
    if (is_read) {
        language = (LANGUAGE)language_value.toInt();//强转，int to enum
        if (language == UI_EN) {
            language_suffix = QString("en");
        }
    }

    //加载qm文件
    QTranslator translator;
    QString loadStr = QString(":/qm/main_widget_")+language_suffix;
    translator.load(loadStr);
    a.installTranslator(&translator);

    //设置成员变量，成员变量的作用用于qm文件的切换。
    MainWidget main_widget;
    main_widget.setTranslator(&translator);
    main_widget.setLanguage(language);
    main_widget.show();



    return a.exec();
}
